package chapter01;

import java.util.Arrays;

public class Test23_Insert {
    public static void main(String[] args) {
        int[] a = {1,2,3};
        int e = 100;
        int pos = 2;
        System.out.println(Arrays.toString(insert(a, e, pos)));
    }
    public static int[] insert(int[] a,int e,int pos){
        int[] b = new int[a.length+1];
        for(int i=0;i<pos;i++){
            b[i] = a[i];
        }
        for(int i=pos;i<a.length;i++){
            b[i+1] = a[i];
        }
        b[pos] = e;
        return b;
    }
}
